package com.hanelalo.gaugepro.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PayAmountController {

  private static final Logger logger = LoggerFactory.getLogger(PayAmountController.class);

  @PostMapping(value = "calc", consumes = "application/json", produces = "application/json")
  public PayAmountResponse calculate(@RequestBody PayAmountRequest request) {
    logger.info("请求信息: {}", request);
    double realAmount = (request.getAmount() * request.getDiscount()) / 100.0;
    PayAmountResponse response = new PayAmountResponse();
    response.setRealAmount(realAmount);
    logger.info("响应信息: {}",response);
    return response;
  }
}
